<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr = [1, 1, 2, 3, 3]

      //filter()和indexOf()实现去重

      const res = arr.filter((item, index, array) => {
        return array.indexOf(item) === index
      })

      console.log(res)

      //reduce()和includes()实现去重

      let res2 = arr.reduce((prev, item) => {
        return prev.includes(item) ? prev : [...prev, item]
      }, [])

      // console.log(res2)

      //Set方式
    </script>
  </body>
</html>
